package com.hsyt.pms.api.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: TODO
 * @author wangze@hsyuntai.com
 * @date 2019年2月12日 下午2:45:51
 */
public enum OrgType {

    FIRE(1, "消防组织"),
    SOCIAL(2, "社会单位组织"),
    INDUSTRY(3, "行业主管组织"),
    BUSINESS(4, "商户组织"),
    TENEMENT(5, "物业组织"),
    ACCEPT_CENTER(6, "受理中心组织"),
    MAINTENANCE(7, "运维组织"),
    MICRO_FIRE(8, "微型消防站"),
    OTHER(99, "其它位组织");

    private Integer value;
    private String name;

    private final static Map<String, OrgType> orgTypeMap = new HashMap<String, OrgType>(10);
    private final static Map<String, String> orgTypePageMap = new HashMap<String, String>(10);
    static  {
        //set type
        orgTypeMap.put("fire", FIRE);
        orgTypeMap.put("social",SOCIAL);
        orgTypeMap.put("industry",INDUSTRY);
        orgTypeMap.put("business",BUSINESS);
        orgTypeMap.put("tenement",TENEMENT);
        orgTypeMap.put("accept_center",ACCEPT_CENTER);
        orgTypeMap.put("maintenance",MAINTENANCE);
        orgTypeMap.put("micro_fire",MICRO_FIRE);
        orgTypeMap.put("other",OTHER);
        //set vm page
        orgTypePageMap.put("fire", "Fire");
        orgTypePageMap.put("social","Social");
        orgTypePageMap.put("industry","Industry");
        orgTypePageMap.put("business","Business");
        orgTypePageMap.put("tenement","Tenement");
        orgTypePageMap.put("accept_center","AcceptCenter");
        orgTypePageMap.put("maintenance","Maintenance");
        orgTypePageMap.put("micro_fire","MicroFire");
        orgTypePageMap.put("other","Other");
    }

    private OrgType(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
//    public static OrgType getOrgType(String orgType) {
//        return orgTypeMap.get(orgType);
//    }
    public static OrgType getOrgType(Integer orgType) {
        for (OrgType oType:  OrgType.values()) {
            if(oType != null && oType.getValue() == orgType) {
                return oType;
            }
        }
        return null;
    }
    public static Integer getOrgTypeValue(String orgType) {
        OrgType oType = orgTypeMap.get(orgType);
        return (oType == null? null: oType.getValue());
    }
    public static String getOrgTypePageValue(String orgType) {
        String vmPageName = orgTypePageMap.get(orgType);
        return (vmPageName == null? "": vmPageName);
    }

}
